package com.ux.iot.jetlinks.service.websocket;


import com.ux.iot.core.service.IotMsgService;
import lombok.extern.slf4j.Slf4j;

import javax.websocket.Session;
import java.util.concurrent.Future;

/**
 * @author caixiaodao
 * @version 1.0
 * 功能描述
 * 单个session 同步消息发送
 * @date 2021/11/15 13:50
 */
@Slf4j
public class SingleEndPointAsyncIotMsgService implements IotMsgService<String, Future<Void>> {

    @Override
    public synchronized Future<Void> send(String msg) {
        log.debug("发送消息{}", msg);
        Session session=SessionManager.getSingleSession();

           return  session.getAsyncRemote().sendText(msg);

    }
}
